From: Georges Basile Stavracas Neto Date: Thu, 13 Aug 2020 23:20:52 +0000 (-0300) Subject: appDisplay: Cache app ids in FolderView X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~684^2^2~25 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=7fcaf63291b4a6dd8a11077e9d4f684bd5b0ea63;p=gnome-shell.git appDisplay: Cache app ids in FolderView Instead of reading a GSettings and building the app ids list every single time FolderView needs to check for something, cache it before redisplay and reuse this cached list everywhere. https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1409 --- diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js index 1c25dfe39..c1fb1cb20 100644 --- a/js/ui/appDisplay.js +++ b/js/ui/appDisplay.js @@ -1604,6 +1604,7 @@ class FolderView extends BaseAppView { action.connect('pan', this._onPan.bind(this)); this._scrollView.add_action(action); + this._appIds = []; this._redisplay(); } @@ -1649,8 +1650,7 @@ class FolderView extends BaseAppView { } _getItemPosition(item) { - const appIds = this._getFolderApps(); - const appIndex = appIds.indexOf(item.id); + const appIndex = this._appIds.indexOf(item.id); if (appIndex === -1) return [-1, -1]; @@ -1660,10 +1660,8 @@ class FolderView extends BaseAppView { } _compareItems(a, b) { - const appIds = this._getFolderApps(); - - const aPosition = appIds.indexOf(a.id); - const bPosition = appIds.indexOf(b.id); + const aPosition = this._appIds.indexOf(a.id); + const bPosition = this._appIds.indexOf(b.id); if (aPosition === -1 && bPosition === -1) return a.name.localeCompare(b.name); @@ -1720,9 +1718,8 @@ class FolderView extends BaseAppView { _loadApps() { let apps = []; let appSys = Shell.AppSystem.get_default(); - const appIds = this._getFolderApps(); - appIds.forEach(appId => { + this._appIds.forEach(appId => { const app = appSys.lookup_app(appId); let icon = this._items.get(appId); @@ -1735,6 +1732,13 @@ class FolderView extends BaseAppView { return apps; } + _redisplay() { + // Keep the app ids list cached + this._appIds = this._getFolderApps(); + + super._redisplay(); + } + acceptDrop(source) { if (!super.acceptDrop(source)) return false;